#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import unit_strategy
import param_cache
import os
import logging


logging.basicConfig(level=logging.INFO)


class UnitShellProcess(unit_strategy.UnitObject):
    def __init__(self):
        super().__init__()

    def process1(self, paramc: param_cache.ParamCache):
        config_dict = paramc.get_param_config()
        for key, value in config_dict.items():
            logging.debug(key + ":" + value)

        ret = os.popen(config_dict['cmd']).read()
        logging.info(ret)

        if not config_dict['comparison'].upper() == 'NULL':
            if not config_dict['comparison'] in ret:
                raise RuntimeError


